package com.zdd.ehe.result;

import lombok.Data;

/**
 * @version 1.0.0
 * @title: Result
 * @author: HFLy
 * @description: 统一的返回的模板
 * @date: 19/2/2023 下午7:31
 */
@Data
public class Result {
    //代码
    private Integer code;
    //消息
    private String message;
    //数据
    private Object data;

    public static Result success(){
        Result result = new Result();
        result.setCode(200);
        return result;
    }
    public static Result success(String message){
        Result result = Result.success();
        result.setMessage(message);
        return result;
    }
    public static Result success(String message,Object data){
        Result result = Result.success(message);
        result.setData(data);
        return result;
    }

    public static Result error(){
        Result result = new Result();
        result.setCode(400);
        return result;
    }

    public static Result error(Integer code,String message){
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

    public static Result error(String message){
        Result result = Result.error();
        result.setMessage(message);
        return result;
    }
    public static Result error(String message,Object data){
        Result result = Result.error(message);
        result.setData(data);
        return result;
    }
}
